/* JqGrid Session List */
function initGridSession() {
	$("#gridList").jqGrid({
		url:'getJqgridSessionList.jsp',
		mtype: 'post',
		//postData: { },
		datatype: "json",
		colNames:['','사용자','원격지','계정','세션','로그인일시','로그아웃일시'],
		colModel:[
				{name:'use_yn',index:'use_yn', width:50,align:"right",key:true},
				{name:'user_id',index:'user_id', width:80,align:"left"},
				{name:'ip_addr',index:'ip_addr', width:180,align:"left"},
				{name:"account",index:'account', width:100,align:"right"},
				{name:'session',index:'session', width:50,align:"right"},
				{name:'login_date',index:'login_date', width:50,align:"right"},
				{name:'logout_date',index:'logout_date', width:50,align:"right"}
			],
		rowList: [0,5,10,15,20],
		rowNum:5,
		height:240,
		autowidth : true,
		sortname: "user_id",
		sortorder: 'DESC',
		viewrecords: true,
		multiselect: true,//앞에 체크박스처리
		multikey: "",//multikey: "ctrlKey/shiftKey",
		pager: '#pager_id',
      
		onSelectRow: function(id){  //row가 선택되었을 경우
		},
		loadComplete : function(data){
			pagecount = data.total;
			$("#pager").pager({ pagenumber: data.page, pagecount: pagecount, buttonClickCallback: PageClick });
        },

		loadError : function(xhr,st,err) {
			//jQuery("#rsperror").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
		},
		emptyrecords: "데이터가 존재하지 않습니다.",
		caption:'테이블',
		jsonReader: {
			repeatitems:false
		}
	});
	$("#gridList").jqGrid('navGrid','#pager_id',{edit:false,add:false,del:false,search:true});
}

/* JqGrid SessionLog List */
function initGridSessionLog() {
	$("#gridList2").jqGrid({
		url:'getJqgridSessionLogList.jsp',
		mtype: 'post',
		//postData: { },
		datatype: "json",
		colNames:['작업시간','원격지','계정','TTY','명령내역'],
		colModel:[
				{name:'work_time',index:'work_time', width:50,align:"right",key:true},
				{name:'ip_addr',index:'ip_addr', width:180,align:"left",editable:true,editoptions:{size:"20",maxlength:"30"}},
				{name:"account",index:'account', width:100,align:"right"},
				{name:'tty',index:'tty', width:50,align:"right",editable:true},
				{name:'command_list',index:'command_list', width:50,align:"right",editable:true}
			],
		rowList: [0,5,10,15,20],
		rowNum:5,
		height:240,
		autowidth : true,
		sortname: "work_time",
		sortorder: 'DESC',
		viewrecords: true,
		multiselect: true,//앞에 체크박스처리
		multikey: "",//multikey: "ctrlKey/shiftKey",
		pager: '#pager_id',
      
		onSelectRow: function(id){  //row가 선택되었을 경우
		},
		loadComplete : function(data){
			pagecount2 = data.total;
			$("#pager2").pager({ pagenumber: data.page, pagecount: pagecount2, buttonClickCallback: PageClick2 });
        },

		loadError : function(xhr,st,err) {
			//jQuery("#rsperror").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
		},
		emptyrecords: "데이터가 존재하지 않습니다.",
		caption:'테이블',
		jsonReader: {
			repeatitems:false
		}
	});
	$("#gridList2").jqGrid('navGrid','#pager_id',{edit:false,add:false,del:false,search:true});
}

var pagecount;
var pagecount2;
var lastsel3;
$(document).ready(function(){
	initGridSession();
	initGridSessionLog();
});
PageClick = function(pageclickednumber) {
    $("#pager").pager({ pagenumber: pageclickednumber, pagecount: pagecount, buttonClickCallback: PageClick });
    $("#gridList").setGridParam({ postData: { pagePlug: pageclickednumber} }).trigger("reloadGrid");  // Postdata을 넘겨주고 url로 지정된 ajax 호출하고 Grid을 Relo
}
PageClick2 = function(pageclickednumber) {
    $("#pager2").pager({ pagenumber: pageclickednumber, pagecount: pagecount2, buttonClickCallback: PageClick2 });
    $("#gridList2").setGridParam({ postData: { pagePlug: pageclickednumber} }).trigger("reloadGrid");  // Postdata을 넘겨주고 url로 지정된 ajax 호출하고 Grid을 Relo
}